Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: OpenDoc Cookbook /
Chapter 1 - Development Environment


Building SamplePart

This section explains how to build an executable SamplePart shared library.

Using the Build Script

The Build Support folder includes a build script named BuildOpenDocPart. You execute the build script with two required arguments: the path to the makefile you wish to use, and a list of the compilers you want to run, in order, in a comma-separated list. You can also specify certain options. The build script command syntax appears as follows:

BuildOpenDocPart -f makefile -b compiler(s) [options]
makefile is an MPW pathname, absolute or relative to the current directory.

compiler(s) is a list of one or more compilers, specified by their MPW tool filenames. The compilers you can use to build OpenDoc parts are specified as follows:

Idl To generate .xh, .xih, and .cpp files

Rez To generate .rsrc files

SCpp To build part with SCpp compiler

SC To build part with SC compiler

MrCpp To build part with MrCpp compiler

MrC To build part with MrC compiler

options if any, can be one or more of the following:

-fat Merge the 68K and PowerPC shared libraries

-k Rebuild all source files

-nopch Don't compile code using precompiled headers

-toco option Temporarily override current setting of compiler option, where option is the option to be overridden, with the setting to use for this compile, specified between straight double quotation marks. For example,

-toco "-d OptimizationOption=speed"

Examples

This section shows some example invocations of the BuildOpenDocPart script.

The following command line performs a Rez build as needed. That is, the Rez resource compiler is invoked to process newly changed source files according to the dependency rules in the SamplePart.make makefile:

BuildOpenDocPart -b rez ∂
      -f '8100:OpenDoc:SampleCode:SamplePart:SamplePart.make'
(The character is the MPW script language continuation symbol; it causes the MPW Shell to execute the two example lines as one.)

The following command line performs a full Interface Definition Language (IDL) build, then a full Rez build, then a full SCpp build:

BuildOpenDocPart -b idl,rez,scpp -k ∂
      -f '8100:OpenDoc:SampleCode:SamplePart:SamplePart.make'
The following command line performs an SCpp build, as needed, then performs a MrCpp build, as needed, then creates a fat binary.

BuildOpenDocPart -b scpp,mrcpp -fat ∂ 
      -f '8100:OpenDoc:SampleCode:SamplePart:SamplePart.make'
The -fat option used in the preceding example merges 68K and PowerPC shared libraries into a fat binary file that will run in native mode on either 68K or PowerPC systems. This option does not drive the build itself but requires the targets to be previously built, as they are in this example, as specified by the -b argument.

Setting OpenDoc Flags

Building OpenDoc parts requires setting certain flags, compiler symbols that must be defined as specified in the file CompDefs.h. The following definition removes SOM-related debug statements from generated code:

#define _RETAIL
The _RETAIL setting in CompDefs.h controls the definition of the ODDebug symbol, required by the Exception Handling (Except) and Debugging (ODDebug) utilities. The _RETAIL setting also controls traceback symbol generation for the PowerPC version of Macsbug. The following logic controls these settings:

#ifdef _RETAIL
   #ifndef ODDebug
   #define ODDebug 0
   #endif
#else
   #ifndef ODDebug
   #define ODDebug 1
   #endif
   #pragma traceback on
#endif
The following definitions indicate that the source code does not use obsolete Mac OS routine names and data structures:

#define OLDROUTINENAMES 0
#define OLDROUTINELOCATIONS 0
The following definition allows the compiler to include, in certain header files only, structures useful to the Mac OS platform:

#define _PLATFORM_MACINTOSH_ 1
The following definition specifies the endian format of the Mac OS platform for the Standard Type I/O (StdTypIO) utility:

#define _PLATFORM_BIG_ENDIAN_ 1

Using Precompiled Headers

Using precompiled headers can significantly shorten compile time when there have been no changes to included files. The Build Support folder contains two header files from which a precompiled header can be generated: the file SCPCHeaders++.pch (for C++ compilers) and the file SCPCHeaders.pch (for the C compilers). These files include OpenDoc headers, OpenDoc utilities, and Mac OS Toolbox headers required to build SamplePart and the other OpenDoc official samples.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
16 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help